package ar.com.ford.it.fullEconomics.persistence.dao.query;

import oracle.toplink.expressions.Expression;
import oracle.toplink.expressions.ExpressionBuilder;
import ar.com.ford.it.fullEconomics.persistence.dto.Teese05Paypolvers;
import ar.com.ford.it.fullEconomics.persistence.dto.Teesg01Plant;
import com.ford.it.persistence.impl.toplink.CustomExpressionFactory;

public class PayPolInDateRangeFindQuery implements CustomExpressionFactory {

    public Expression createExpression(ExpressionBuilder builder,
                                       Object[] parameters) {
        Expression exp = null;
        Teese05Paypolvers payPolVers = (Teese05Paypolvers) parameters[0];

        Teesg01Plant plant = payPolVers.getEese05PlantCodeC();

        exp = builder.get("eese05PlantCodeC").equal(plant);
        exp = exp.and(builder.get("eese05PpyverApprovalUserC").notNull());
        exp = exp.and(builder.get("teese04Paypolicy").equal(
                payPolVers.getTeese04Paypolicy()));
        exp = exp.and(builder.get("eese05PpyverInDateY").between(
                payPolVers.getEese05PpyverInDateY(),
                payPolVers.getEese05PpyverOutDateY()));

        return exp;
    }

}
